package com.du.spring.dao.impl;

import com.du.spring.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

/**
 * @author : DuJiabao
 * @Date : 2021/3/18 11:52
 * @Project : spring
 * @File : null.java
 * @Desc :
 */
@Repository
public class AccountDaoImpl implements AccountDao {
  JdbcTemplate jdbcTemplate;  // 自动注入

  @Override
  public int changeAccount(int id, BigDecimal money) {
    String sql = "update account set money = money + ? where id = ?";
    return jdbcTemplate.update(sql, money, id);
  }

  @Autowired
  public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
    this.jdbcTemplate = jdbcTemplate;
  }
}
